package com.mux.util.common;

import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang.StringEscapeUtils;
/**
 * 
 * @author devin.chen
 *
 */
public class CommUtil {
	
	/**
	 * 由于采用动态拼接sql,为防止sql 注入，对用户输入转义
	 * @param param  sql 参数,用户输入
	 * @return
	 */
	public static String excapeParam(String param){
		return StringEscapeUtils.escapeSql(param);
	}
	
	/**
	 *  
	 * @param url https://sfadev.cccil.com.cn:8100/RED/Insert_TRepMain?digest=4c2993265bc821e18c6fc79dfaa9a309e2f7d0eafa7f53cdbcd5745711feb07f
	 * @param hp
	 * @return
	 */
	public static Map<String,String> getRequestStr(String url){
		Map<String,String> map = new HashMap<String,String>();
		
		int n = url.indexOf("//")+2;
		int n2 = url.lastIndexOf(":");
		
		String host = url.substring(n,n2);
		String port = url.substring(n2+1,n2+5);
		
		map.put("host",host);
		map.put("port",port);
		
		return map;
	}
	
	

}
